//
//  RCHomeViewController.m
//  RCsinaMicroBlog
//
//  Created by Mr.Ray on 15/1/31.
//  Copyright (c) 2015年 Ray.peng. All rights reserved.
//

#import "RCHomeViewController.h"
#import "RCtitleButton.h"
#import "RCPopMenuView.h"
#import "RCtestController.h"
#import "UIBarButtonItem+Extension.h"
@interface RCHomeViewController ()
@end
@implementation RCHomeViewController

- (void)viewDidLoad{
    [self setupNav];
    
    self.defaultCenterView.iconImageName = @"visitordiscover_feed_image_house";
    self.defaultCenterView.info = @"当你关注一些人以后，他们发布的最新消息会显示在这里";
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.defaultCenterView startRotate];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.defaultCenterView stopRotate];
}

- (void)setupNav{
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"navigationbar_friendsearch" higImage:@"navigationbar_friendsearch_highlighted" target:self action:@selector(friendsearch)];
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage:@"navigationbar_pop" higImage:@"navigationbar_pop_highlighted" target:self action:@selector(scan)];
    
    //初始化导航条
    RCtitleButton *btn = [[RCtitleButton alloc]init];
    [btn setTitle:@"首页" forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateSelected];
    //自动调整尺寸
    [btn sizeToFit];
    
    [btn addTarget:self action:@selector(titleBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.titleView = btn;
    
}

- (void)titleBtnClick:(RCtitleButton *)btn{
    
    btn.selected = !btn.selected;

    RCtestController *test = [[RCtestController alloc]init];
    test.view.size = CGSizeMake(150, 200);
    
    [RCPopMenuView popMenuView:btn contentVc:test dismiss:^{
        btn.selected = !btn.selected;

    }];

}


- (void)scan{
    
}

- (void)friendsearch{
    DDActionLog;
}

#pragma mark - 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

@end
